#!/usr/bin/env python

import wx
import view

from _image import Image
from _info import Info

class Anime(wx.Panel):
    '''Anime class
    
    @author Julot <andy.julot@gmail.com>
    @since Friday, January 27, 2012. 05:20 PM'''
    
    def __init__(self, *args, **kwargs):
        wx.Panel.__init__(self, *args, **kwargs)
        
        self.splitterV = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE)
        
        self.splitterH = wx.SplitterWindow(self.splitterV,
                                           style=wx.SP_LIVE_UPDATE)
        
        self.image = Image(self.splitterH)
        self.info = Info(self.splitterH)
        
        self.splitterH.SetMinimumPaneSize(20)
        self.splitterH.SplitVertically(self.image, self.info)
        
        style = wx.TE_MULTILINE | wx.TE_WORDWRAP | wx.TE_RICH2
        self.description = wx.TextCtrl(self.splitterV, style=style)
        
        self.splitterV.SetMinimumPaneSize(20)
        self.splitterV.SplitHorizontally(self.splitterH, self.description)
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.splitterV, 1, wx.GROW)
        self.SetSizerAndFit(sizer)
    
    _value = None
    
    def getValue(self):
        return self._value
    
    def setValue(self, value):
        self._value = value
        self.info.value = value
        if value.hasPicture:
            self.image.path = value.picturePath
        else:
            self.image.clear()
        self.description.Value = value.humanDescription
    
    value = property(getValue, setValue)
    
    def clear(self):
        self.info.clear()
        self.image.clear()
        self.description.Value = ''